<template>
    <div>
        <table class="table">
            <thead>
                <tr>
                    <td>房间号</td>
                    <td>
                        <input type="text" v-model="date.houseNum">
                    </td>
                </tr>
                <tr>
                    <td>房间名称</td>
                    <td>
                        <input type="text" v-model="date.houseName">
                    </td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <input type="checkbox" v-model="date.state">勾选为启用,否则禁用
                    </td>
                </tr>
                <tr>
                    <td>开始时间</td>
                    <td>
                        <input type="date" v-model="date.start">
                    </td>
                </tr>
                <tr>
                    <td>结束时间</td>
                    <td>
                        <input type="date" v-model="date.end">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <input type="button" value="新增" @click="add">
                    </td>
                </tr>
            </thead>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { useRouter } from 'vue-router';
import { ref } from 'vue';
const routher = useRouter()
const add=()=>{
    axios.post("/api/House/AddHouse",date.value).then(res=>{
        if(res.data>0){
            alert("新增成功")
            routher.push({path:"/Show"})
        }
        else{
            alert("新增失败")
        }
    })
}
const date=ref({
  "houseId": 0,
  "houseNum": "",
  "houseName": "",
  "state": false,
  "start": "",
  "end": ""
})
</script>

<style scoped>

</style>